package de.jmda.sample.mproc;

import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Set;

import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;

import de.jmda.core.MarkerAnnotationType;
import de.jmda.core.mproc.LaunchConfiguration;
import de.jmda.core.mproc.Launcher;
import de.jmda.core.mproc.Processor;
import de.jmda.core.util.FileUtil;

@SupportedAnnotationTypes(value = { "de.jmda.core.MarkerAnnotationType" })
@SupportedSourceVersion(value = SourceVersion.RELEASE_7)
public class HelloWorldProcessor extends Processor
{
	@Override
	protected Set<Class<? extends Annotation>> getSupposedSupportedAnnotationTypes()
	{
		return asSet(MarkerAnnotationType.class);
	}

	@Override
  protected boolean process()
  {
		System.out.println("hello world");
	  return false;
  }

	@MarkerAnnotationType private class AnAnnotatedType {}

	public static void main(String[] args) throws IOException
  {
	  File file =
	  		new File(
	  				"src/main/java",
	  				FileUtil.toSourceFilePath(HelloWorldProcessor.class));

		HelloWorldProcessor processor = new HelloWorldProcessor();

		LaunchConfiguration configuration = new LaunchConfiguration();
		
		configuration.files.add(file);
		configuration.processors.add(processor);
		
		Launcher.launch(configuration);
  }
}